export default {
  addCart({
    state,
    commit
  }, payload) {
    return new Promise((resolve, reject) => {
      let list = JSON.parse(localStorage.getItem('cartList')) || []
      if (list) {
        let oldProduct = state.cartList.find(item => item.iid === payload.iid)
        if (oldProduct) {
          // oldProduct.count +=1
          commit('addCounter', oldProduct)
          resolve()
        } else {
          commit('addToCart', payload)
          resolve('添加了新的商品')
        }
      }
    })
  },


}